class Solution {
    const int MOD = 1e9 + 7;
public:
    int countOfPairs(vector<int>& nums) {
        int n = nums.size(), m = ranges::max(nums);
        vector<vector<int>> f(n, vector<int>(m + 1, 1));
        for(int i = 1; i < n; i++){
            for(int j = 0; j <= nums[i]; j++){
                int res = 0;
                for(int k = 0; k <= min({j, nums[i-1],j + nums[i-1] - nums[i]}); k++){
                    res = (res + f[i-1][k])%MOD;
                }
                f[i][j] = res;
            }
        }
        int ans = 0;
        for(int i = 0; i <= nums.back(); i++)
            ans = (ans + f[n-1][i])%MOD;
        return ans;
    }
};